package top.iocn.site.controller;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import top.iocn.site.pojo.TCardReportChannel;
import top.iocn.site.pojo.TCardReportChannelExample;
import top.iocn.site.pojo.TSysAdmin;
import top.iocn.site.service.AdminService;
import top.iocn.site.service.ReportChannelService;



@Controller
@RequestMapping("/admin")
public class AdminController {
	@Resource
	private AdminService adminService;
	@Autowired
	private ReportChannelService reportChannelService;
	
	@RequestMapping(value="/insert")
	public String insert(TSysAdmin record){
		System.out.println("---action.record:"+record);
		try {
			record.setAddTime(new Date());
			record.setUpdateTime(new Date());
			int insert = adminService.insert(record);
			if(insert>0){
				return "forward:/jsp/success.jsp";
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "forward:/jsp/fail.jsp";
	}
	
	@RequestMapping(value="/select")
	public void select(){
		TCardReportChannelExample example = new TCardReportChannelExample();
		
		TCardReportChannelExample.Criteria criteria = example.createCriteria();
		criteria.andChannelCodeEqualTo("200010");
		List<TCardReportChannel> list = reportChannelService.selectByExample(example);
		for (int i = 0; i < list.size(); i++) {
			System.out.println(list.get(i).getId());
		}
	}
	@RequestMapping(value="/sss")
	public String seleccc(){
		return "NewFile";
	}
	
	@RequestMapping(value="/cccc")
	public String seleccsssc(HttpRequest request){
		return "NewFile";
	}
	
}

